package com.tian.excel.controller;

import com.tian.excel.service.OrderService;
import com.tian.excel.vo.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author: Tian
 * @version: 1.0
 * @since: 1.0
 * @date: 2024/8/2/16:01
 */
@RestController
@RequestMapping("/order")
@Api(tags = "订单管理")
public class OrderController {
    @Autowired
    OrderService orderServiceImpl;

    @PostMapping("createNavite/{orderNo}")
    public R createNavite(@PathVariable String orderNo) {
        return orderServiceImpl.createNative(orderNo);
    }

    @PostMapping("queryWeiXinStatus/{orderNo}")
    public R query(@PathVariable String orderNo) {
        return orderServiceImpl.queryWeiXinPayStatus(orderNo);
    }

    @PostMapping("/zhiFuBaoPay/{orderNo}")
    public R createZhiFuBaoNative(@PathVariable String orderNo){
        return orderServiceImpl.zhiFuBaoEasyPay(orderNo);
    }

    @PostMapping("/notify")
    public  R notify(HttpServletRequest request){
        System.out.println("收到支付成功通知");
        String no=request.getParameter("out_trade_no");
        System.out.println("=========订单号==========");
        System.out.println(no);
        System.out.println("========================");
        return new R(200,"支付成功,稍后发货",null);
    }


    @PostMapping("queryZFBStatus/{orderNo}")
    public R queryZFBPayStatus(@PathVariable String orderNo) {
        return orderServiceImpl.queryZFBPayStatus(orderNo);
    }


}
